﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="departmentals.aspx.cs" Inherits="Mocola.Net.Web.departmentals" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>部门管理</title>
    <meta name="description" content="CsLand Ams v1.0 - 部门管理" />
    <meta http-equiv="X-UA-Compatible" content="IE=7" />

    <link rel="stylesheet" href="css/content.css" type="text/css" />
    <link rel="stylesheet" href="css/ui.css" type="text/css" />
    <link rel="stylesheet" href="css/sys.css" type="text/css" />
   	<link rel="stylesheet" href="css/table.css" type="text/css" />
   	
   	<link rel="stylesheet" media="screen" href="css/vlaCal-v2.1.css" type="text/css" />
	<link rel="stylesheet" media="screen" href="css/vlaCal-v2.1-adobe_cs3.css" type="text/css" />
	<link rel="stylesheet" media="screen" href="css/vlaCal-v2.1-apple_widget.css" type="text/css" />
	<link rel="stylesheet" href="scripts/formcheck/theme/classic/formcheck.css" type="text/css" media="screen" />
	
    <!--[if IE]>
	    <script type="text/javascript" src="scripts/excanvas-compressed.js"></script>	
	    <style type="text/css"> html { overflow: auto; } </style>	
    <![endif]-->
    	
    <script type="text/javascript" src="scripts/mootools-1.2-core.js"></script>
    <script type="text/javascript" src="scripts/mootools-1.2-more.js"></script>	
    <script type="text/javascript" src="scripts/mocha.js"></script>
    <script type="text/javascript" src="scripts/mocola-funs.js"></script>
    <script type="text/javascript" src="scripts/vlaCal-v2.1-compressed.js"></script>
    <script type="text/javascript" src="scripts/vlaCal-v2.1-clientside.js"></script>
    <script type="text/javascript" src="scripts/formcheck/lang/cn.js"> </script>
    <script type="text/javascript" src="scripts/formcheck/formcheck.js"> </script>
</head>
<body style="padding: 5px;">
    <form id="form1" runat="server">
    <div class="dvspec" style="margin-top: 5px;" id="DvDept">
        <div style="padding: 10px; overflow: auto;height:500px;">
            <div class="title1">部门列表：</div>
            <table class="table2" cellspacing="0" style="margin-top: 5px; border: 1px #C1DAD7 solid; ">
                <tr>
                    <th style="width: 5%">
                    <asp:CheckBox ID="chkMap_All" runat="server" onclick="ChkAll(this,'DvDept')" />
                    </th>
                    <th style="width: 5%">
                        #
                    </th>
                    <th style="width: 60%">
                        部门名称
                    </th>
                    <th style="width: 30%">
                        操作
                    </th>
                 </tr>
            <asp:Repeater ID="rptDept" runat="server">
                <ItemTemplate>
                    <tr>
                        <td align="center"><asp:CheckBox ID="chkDeptItem" runat="server" /></td>
                        <td><%# Eval("ID")%></td>
                        <td><span id='pView_<%# Eval("ID")%>'><font color="#666"><%# Eval("Name")%></font></span>
                        <span id='pEdit_<%# Eval("ID")%>' style="display:none">
                            <input id='pEdit_Text_<%# Eval("ID")%>' type="text" value="<%# Eval("Name")%>" class="inputbox"/>
                            &nbsp;<input type="button" class="btnzc" value="更新" onclick="update(<%# Eval("ID")%>)"/>
                        </span>
                        </td>
                        <td align="center">
                            <input type="button" value="编辑" class = "btnzc" onclick='modeEdit(<%# Eval("ID")%>)'/>
                            <input type="button" value="删除" class = "btnzc" onclick="delDept(<%# Eval("ID")%>)"/>
                        </td>
                    </tr>
                </ItemTemplate>
            </asp:Repeater>
            </table>
        </div>
        <div class="dvspecalt">
        <div style="padding: 5px;">
            部门名称：<input type = "text" id = "DeptName" class="inputbox" runat = "server"/>
            <asp:HiddenField ID = "hfDeptID" runat = "server"/>
            <asp:button ID= "btnSave" Text = "新增" runat="server" CssClass= "btnzc" 
                onclick="btnSave_Click" />
        </div>
    </div>
    </div>
    <script type="text/javascript">
        function ChkAll(obj, tagID) {
            var arr = $(tagID).getElementsByTagName("input");
            {
                for (var i = 0; i < arr.length; i++) {
                    arr[i].checked = obj.checked;
                }
            }
        }
        function delDept(ID)
        {
            new window.parent.MochaUI.Window({
                    id: 'delFileMap',
				    title: '删除部门',
				    loadMethod: 'iframe',
				    contentURL: 'ajax/ShowPwd.aspx?zl=Dept&id='+ID+'&lb=Dept&tid=0&eid=0',
				    width: 300,
				    height: 200,
				    maximizable: false,
				    resizable:false
			    });
        }
        
        function modeEdit(id)
        {
            if($('pEdit_'+id).style.display=='none') {
               $('pEdit_'+id).style.display='block';
               $('pView_'+id).style.display='none';
            }
            else
            {
               $('pEdit_'+id).style.display='none';
               $('pView_'+id).style.display='block';
            }
        }

        function update(id)
        {
            var updateValue = $('pEdit_Text_'+id).value;
            var reqValues = new Request.HTML({ url: "ajax/UpdateDept.aspx?id=" + id +"&name=" +  escape(updateValue),
                onSuccess: function(html) {
                    window.parent.$('mainPanel_iframe').src = window.parent.$('mainPanel_iframe').src;
                    alert(html.item(0).nodeValue);
                    location.replace('departmentals.aspx');
                },
                onFailure: function() {
                    alert('列表提交失败！');
                }
            }).post($('frmNewFile'));
        }

    </script>
    </form>
</body>
</html>
